home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
PROGASIC
/
BASFILES.LZH
/
BASTOBIN.BAS
< prev
next >
Wrap
BASIC Source File
|
1988-09-10
|
756b
|
27 lines
'$INCLUDE:'QBTOOLS.INC'
'' DECLARE FUNCTION BaseToBin$ (Numbase%, Number$)
'' '$INCLUDE: 'qbtools.inc'
FUNCTION BaseToBin$ (Numbase%, Number$) STATIC
Base10% = BaseToReal(Numbase%, Number$) 'Convert to base 10
out$ = "" 'Clear output string
IF Base10% = -1 THEN 'Return error if error
BaseToBin$ = "-1" ' in calculating base 10
EXIT FUNCTION
END IF
FOR i% = 7 TO 0 STEP -1 'Conversion
IF Base10% AND 2 ^ i% THEN
out$ = out$ + "1"
ELSE
out$ = out$ + "0"
END IF
NEXT i%
BaseToBin$ = out$ 'Return to Function
END FUNCTION